FROM jenkins:latest

MAINTAINER lijf <lijf@zts.com.cn>

USER root

RUN apt-get update 
# jdk and git have been installed in jenkins
RUN apt-get install -y wget  curl openssh-server 

#install unzip
RUN apt-get install -y unzip

#install jq
RUN apt-get install -y jq 

# install groovy
RUN wget -q --no-check-certificate https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.7.zip   -O /tmp/apache-groovy-binary-2.4.7.zip
RUN unzip /tmp/apache-groovy-binary-*.zip -d /opt
RUN ln -s /opt/groovy-* /opt/groovy
RUN ln -s /opt/groovy/bin/groovy /usr/local/bin
RUN rm -f  /tmp/apache-groovy-binary-*.zip
ENV GROOVY_HOME /opt/groovy

RUN rm -rf /var/lib/apt/lists/*

RUN mkdir -p $JENKINS_HOME/plugins/ 
RUN chown -R jenkins:jenkins "$JENKINS_HOME"

RUN mkdir /var/run/sshd

EXPOSE 22 

USER jenkins
#install plugins
ARG  plugins="git ssh gitlab-plugin ssh-slaves timestamper \
              credentials-binding build-with-parameters dynamicparameter \
			  dynamic_extended_choice_parameter uno-choice managed-scripts \
			  config-file-provider \
			   "
RUN for plugin in ${plugins} ; do \
        /usr/local/bin/install-plugins.sh $plugin ;done



